﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Red.Core
{
    /// <summary>
    ///     Routed command expanded with an icon and some logic.
    /// </summary>
    public class RedCommand : RoutedUICommand
    {
        #region Data
        
        private static Canvas _defaultIcon;
        
        #endregion Data

        #region Properties
        
        /// <summary>
        ///     Canvas object representing a command's icon.
        /// </summary>
        public Canvas Icon { get; set; }

        /// <summary>
        ///     Determines, if the command belongs to a 'more important' category.
        ///     A control on which the command list is exposed decides how to interpret this.
        /// </summary>
        public bool IsPrimary { get; set; }

        #endregion Properties

        #region C-tor
        
        static RedCommand()
        {
            _defaultIcon = (Canvas)Application.Current.FindResource( "appbar_arcade_button" );
        }

        public RedCommand()
        {
            Icon = _defaultIcon;
            IsPrimary = false;
        }

        public RedCommand( string text, string iconName, bool isPrimary = false )
        {
            Icon = String.IsNullOrEmpty( iconName ) 
                ? _defaultIcon
                : (Canvas)Application.Current.FindResource( iconName );
            Text = text;
            IsPrimary = isPrimary;
        }

        #endregion C-tor
    }
}
